package commodity

import (
	"github.com/flipped-aurora/gin-vue-admin/server/api/v1"
	"github.com/flipped-aurora/gin-vue-admin/server/middleware"
	"github.com/gin-gonic/gin"
)

type CommodityRouter struct {
}

// InitCommodityRouter 初始化 Commodity 路由信息
func (s *CommodityRouter) InitCommodityRouter(Router *gin.RouterGroup) {
	commodityRouter := Router.Group("commodity").Use(middleware.OperationRecord())
	commodityRouterWithoutRecord := Router.Group("commodity")
	var commodityApi = v1.ApiGroupApp.CommodityApiGroup.CommodityApi
	{
		commodityRouter.POST("createCommodity", commodityApi.CreateCommodity)             // 新建Commodity
		commodityRouter.DELETE("deleteCommodity", commodityApi.DeleteCommodity)           // 删除Commodity
		commodityRouter.DELETE("deleteCommodityByIds", commodityApi.DeleteCommodityByIds) // 批量删除Commodity
		commodityRouter.PUT("updateCommodity", commodityApi.UpdateCommodity)              // 更新Commodity

		commodityRouter.GET("", commodityApi.Commodity)
		commodityRouter.POST("create", commodityApi.CommodityCreate)
		commodityRouter.DELETE("delete", commodityApi.DeleteCommodity)
		commodityRouter.PUT("update", commodityApi.CommodityUpdate)
		commodityRouter.GET("list", commodityApi.CommodityList)
	}
	{
		commodityRouterWithoutRecord.GET("findCommodity", commodityApi.FindCommodity)       // 根据ID获取Commodity
		commodityRouterWithoutRecord.GET("getCommodityList", commodityApi.GetCommodityList) // 获取Commodity列表
	}
}
